<!--{template common/header_simple_start}-->
<link href="static/css/common.css?{VERHASH}" rel="stylesheet" media="all">
<script type="text/javascript" src="static/js/jquery.leftDrager.js?{VERHASH}"></script>
<script src="admin/scripts/admin.js?{VERHASH}"></script>
<style>
html,body{
	overflow:hidden;
	background:#FBFBFB;
}
.bs-left-container{
	width:120px;
}
.bs-main-container{
	margin-left:120px;
	overflow:auto;
}

</style>
<!--{template common/header_simple_end}-->

<div class="bs-container clearfix">
  <div class="bs-left-container  clearfix">
    <!--{template left}--> 
  </div>
  <div class="left-drager">
     <div class="left-drager-op"><div class="left-drager-sub"></div></div>
  </div>
      
  <div class="bs-main-container  clearfix"  style="min-width:250px">
  	
        <div class="main-header ">
       	 	<ul class="nav nav-pills nav-pills-bottomguide">
                <li ><a href="{BASESCRIPT}?mod=setting&operation=smiley">表情设置</a></li>
              	<li><a href="{BASESCRIPT}?mod=setting&op=smiley">表情分类</a></li>
                <li class="active"><a href="{BASESCRIPT}?mod=setting&operation=$operation&op=smiley&id=$id">详细 - $smtype[name]</a></li>
             </ul>
              
        </div>
       
  		<div class="main-content clearfix" style="border-top:1px solid #FFF">
         <form id="appform" name="appform" class="form-horizontal" action="{BASESCRIPT}?mod=setting&op=smiley&operation=edit" method="post" >
            <input type="hidden" name="editsubmit" value="true" />
            <input type="hidden" name="id" value="$id" />
            <input type="hidden" name="formhash" value="{FORMHASH}" />
           <table class="table table-hover" >
                <thead>
                  <th width="30">&nbsp;</th>
                  <th>排序</th>
                  <th>图片</th>
              	  <th>表情ID</th>
                  <th>表情代码</th>
                  <th>表情描述</th>
                  <th>文件名</th>
                </thead>
             <!--{loop $list $key $value}-->
                <tr>
                  <td align="center">
                 	 <input type="checkbox"  name="delete[]" value="$value[id]" />
                  </td>
                  <td ><input type="text" class="form-control" style="width:45px;"  name="displayorder[{$value[id]}]" value="$value[displayorder]" style="width:20px;" /></td>
                  <td><img src="$smurl/$value[url]" border="0" onload="if(this.height>30) {this.resized=true; this.height=30;}" onmouseover="if(this.resized) this.style.cursor='pointer';" onclick="if(!this.resized) {return false;} else {window.open(this.src);}"></td>
                   <td >$value[id]</td>
                   <td ><input type="text" class="form-control" name="code[{$value[id]}]" id="code_{$key}" value="$value[code]" smileyid="$value[id]" /></td>
                   <td ><input type="text" class="form-control" name="title[{$value[id]}]" id="title_{$key}" value="$value[title]"  /></td>
                  <td>$value[url]<input type="hidden" value="$value[url]" id="url_{$key}" /></td>
                </tr>
             <!--{/loop}-->
             <tr>
                <td></td>
                <td colspan="8" style="">
                批量设置表情代码 
                <input type="text"  style="margin-right:0;width:40px;height:30px;padding:2px 4px"  value="{:" title="前缀" id="prefix" onclick="clearinput(this, '前缀')"> 
                + 
                <select id="middle" style="width:100px;height:30px;padding:2px 4px">
                <option value="1">文件名</option>
                <option value="2">自然顺序</option>
                <option value="3">表情 ID</option>
                <option value="4">表情描述</option>
                </select> 
                + 
                <input type="text"   style="margin-right:0;width:40px;height:30px;padding:2px 4px" value=":}" title="后缀" id="suffix" onclick="clearinput(this, '后缀')"> 
                <input type="button" class="btn btn-default" onclick="addsmileycodes('{$smileynum}', '');" value="应用">
                 &nbsp;&nbsp; <input type="button" class="btn btn-default" onclick="autoaddsmileycodes('{$smileynum}');" value="自动设置">
                 </td>
                </tr>
              <thead>
                 <th colspan="15"  valign="middle"><label for="chkall" class="checkbox-inline"><input type="checkbox" name="chkall" id="chkall"  onclick="checkAll('prefix', this.form, 'delete')">&nbsp;删？</label>&nbsp;&nbsp;<input type="submit" class="btn btn-primary" value="提交" /></th>
             </thead>
            </table>
          </form>
    </div>
   </div>
</div>
<script type="text/JavaScript">
jQuery('.left-drager').leftDrager_layout();
	function addsmileycodes(smiliesnum, pre) {
		smiliesnum = parseInt(smiliesnum);
		if(smiliesnum > 1) {
			for(var i = 1; i < smiliesnum; i++) {
				var prefix = trim($(pre + 'prefix').value);
				var suffix = trim($(pre + 'suffix').value);
				var page = parseInt('$page');
				var middle = $(pre + 'middle').value == 1 ? $(pre + 'url_' + i).value.substr(0,$(pre + 'url_' + i).value.lastIndexOf('.')) : ($(pre + 'middle').value == 2 ? i + page * 10 : ($(pre + 'middle').value == 3 ? $(pre + 'code_'+ i).attributes['smileyid'].nodeValue:$(pre + 'title_'+ i).value));
				if(!prefix || prefix == '前缀' || !suffix || suffix == '后缀') {
					alert('请输入表情前缀及后缀，建议使用 [ ( : 等符号作为前缀，] ) : 等符号作为后缀');
					return;
				}
				suffix = !suffix || suffix == '后缀' ? '' : suffix;
				$(pre + 'code_' + i).value = prefix + middle + suffix;
			}
		}
	}
	function autoaddsmileycodes(smiliesnum) {
		smiliesnum = parseInt(smiliesnum);
		if(smiliesnum > 1) {
			for(var i = 1; i < smiliesnum; i++) {
				$('code_' + i).value = '{:' + '$id' + '_' + $('code_'+ i).attributes['smileyid'].nodeValue + ':}';
			}
		}

	}
	function clearinput(obj, defaultval) {
		if(obj.value == defaultval) {
			obj.value = '';
		}
	}
</script>
<!--{template common/footer_simple}-->
